package com.jinniulive.platform.module.login.fragments;


import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.jinniulive.platform.R;
import com.jinniulive.platform.adapter.PopupAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * A simple {@link Fragment} subclass.
 */
public class PopupFragment extends Fragment {


    public PopupFragment() {
        // Required empty public constructor
    }


    private TabLayout mTabLayout;
    private ViewPager mViewPager;
    private List<Fragment> mFragments;
    private PopupAdapter mAdapter;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_popup, container, false);
        initView(view);
        initData();




        return view;


    }

    private void initData() {
        mFragments=new ArrayList<>();
        mFragments.add(new SubPopupFragment());
        mFragments.add(new SubPopupFragment());
        mFragments.add(new SubPopupFragment());
        mAdapter=new PopupAdapter(getChildFragmentManager(),getContext(),mFragments);
        mViewPager.setAdapter(mAdapter);
        mTabLayout.setupWithViewPager(mViewPager);

    }

    private void initView(View view) {
        mTabLayout = (TabLayout) view.findViewById(R.id.fragment_popup_tab_layout);
        mViewPager = (ViewPager) view.findViewById(R.id.fragment_popup_view_pager);


    }

}
